import requests
from requests.exceptions import RequestException

class HttpClient:
    @staticmethod
    def get(url, params=None, headers=None):
        """发送GET请求"""
        try:
            response = requests.get(
                url=url,
                params=params,
                headers=headers,
                timeout=10
            )
            response.raise_for_status()
            return response
        except RequestException as e:
            raise Exception(f"GET请求失败: {str(e)}")

    @staticmethod
    def post(url, data=None, json=None, headers=None):
        """发送POST请求"""
        try:
            response = requests.post(
                url=url,
                data=data,
                json=json,
                headers=headers,
                timeout=10
            )
            response.raise_for_status()
            return response
        except RequestException as e:
            raise Exception(f"POST请求失败: {str(e)}")